home *** CD-ROM | disk | FTP | other *** search
- #ifndef __ACGI__
- #define __ACGI__
-
- #include <Threads.h>
-
- void ACGILog(char *msg);
-
- // -----------------------------------------------------
-
- enum {
- errWWWNoMemory = -1,
- errWWWUnexpected = -2,
- errWWWRefused = -3,
- errWWWTooBusy = -4
- };
-
- // -----------------------------------------------------
-
- typedef struct WWWRequestRecord {
- char *pathArgs;
- char *username;
- char *password;
- char *fromUser;
- char *clientAddress;
- char *serverName;
- char *serverPort;
- char *scriptName;
- char *contentType;
- char *referer;
- char *userAgent;
- char *action;
- char *actionPath;
- char *method;
- char *clientIP;
- char *fullRequest;
- char *connectionID;
-
- char *searchArgs;
- char *postArgs;
-
- long searchNum;
- Handle searchNames;
- Handle searchValues;
-
- long postNum;
- Handle postNames;
- Handle postValues;
-
- Handle storage;
- Handle response;
-
- AppleEvent *event; // Just in case you need to get at the raw information
- // in the event...
-
- Boolean isLocked;
- } WWWRequestRecord, *WWWRequest;
-
- // -----------------------------------------------------
-
- void ACGIFatal(char *reason);
- void ACGIShutdown(void);
- Boolean ACGIIsShuttingdown(void);
- Boolean ACGIRefuse(Boolean refuse);
- unsigned long ACGIGetRunningThreads(void);
- unsigned long ACGIGetMaxThreads(void);
- void ACGISetMaxThreads(unsigned long newThreads);
- void ACGIGetSleeps(long *whenThreads, long *whenIdle);
- void ACGISetSleeps(long whenThreads, long whenIdle);
- long ACGIGetWNEDelta(void);
- void ACGISetWNEDelta(long newDelta);
- void ACGIGetThreadParams(Size *stack, ThreadOptions *options);
- void ACGISetThreadParams(Size stack, ThreadOptions options);
- const char *ACGIGetHTTPHeader(void);
-
- // -----------------------------------------------------
-
- typedef enum WWWParameter {
- p_path_args = 0,
- p_username,
- p_password,
- p_from_user,
- p_client_address,
- p_server_name,
- p_server_port,
- p_script_name,
- p_content_type,
- p_referer,
- p_user_agent,
- p_action,
- p_action_path,
- p_method,
- p_client_ip,
- p_full_request,
- p_connection_id
- } WWWParameter;
-
- // [1] Lock down 'request' parameters before accessing contents.
-
- Boolean HTTPLockParams(WWWRequest r);
-
- // [2] Unlock the request parameters.
-
- void HTTPUnlockParams(WWWRequest r);
-
- // [3] Get a pointer to one of the parameter strings.
- // This leaves 'r' locked.
-
- const char *HTTPGetParam(WWWRequest r, WWWParameter par);
-
- /// [4] Get the integer value of a parameter. Result is returned
- // in 'i'. Function returns 'false' if the parameter is
- // not an integer.
-
- Boolean HTTPGetLong(WWWRequest r, WWWParameter par, long *i);
-
- // [5] Copy parameter text into character variable 'result'. Length of your character
- // variable is in 'len', the actual length of the parameter is returned in
- // 'actualLen'. Function return 'false' if the parameter identifier 'par' is invalid.
-
- Boolean HTTPCopyParam(WWWRequest r, WWWParameter par, char *result, long len, long *actualLen);
-
- // [6/7] Get number of SEARCH/POST arguments.
-
- long HTTPGetNumSrchArgs(WWWRequest r);
- long HTTPGetNumPostArgs(WWWRequest r);
-
- // [8/9] Get a SEARCH/POST argument by absolute position. 'index' is between
- // 1 and the total number of SEARCH/POST arguments. 'name' receives the
- // name of the argument at position 'index' and 'value' receives the value.
- // The lengths of the character arrays 'name' and 'value' are in 'nameLen'
- // and 'valueLen'. The actual lengths of the items are returned in
- // 'actualNameLen' and 'actualValueLen'. Function returns 'false' if 'index'
- // is out of range.
-
- Boolean HTTPGetSrchArgAt(WWWRequest r, long index, char *name,
- long nameLen, long *actualNameLen, char *value,
- long valueLen, long *actualValueLen);
-
- Boolean HTTPGetPostArgAt(WWWRequest r, long index, char *name,
- long nameLen, long *actualNameLen, char *value,
- long valueLen, long *actualValueLen);
-
- // [10/11] Get number of SEARCH/POST arguments that have the same field
- // name 'name'. Number is returned in 'numValues'. Function return
- // 'false' if there is no SEARCH/POST argument called 'name'.
-
- Boolean HTTPGetSrchArgCount(WWWRequest r, char *name, long *numValues);
- Boolean HTTPGetPostArgCount(WWWRequest r, char *name, long *numValues);
-
- // [12/13] Try to get instance 'index' of a multi-valued SEARCH/POST argument.
- // Function returns empty string if 'index' is out of range or if 'name' doesn't
- // exist. Function leaves 'r' locked on exit.
-
- const char *HTTPGetMultipleSrchArg(WWWRequest r, char *name, long index);
- const char *HTTPGetMultiplePostArg(WWWRequest r, char *name, long index);
-
- // [14/15] Get integer value of instance 'index' of a multi-valued SEARCH/POST
- // argument called 'name'. Function returns value in 'i'. Function returns
- // 'false' if 'index' is out of range or the argument is not an integer.
-
- Boolean HTTPGetLongMultipleSrchArg(WWWRequest r, char *name, long index, long *i);
- Boolean HTTPGetLongMultiplePostArg(WWWRequest r, char *name, long index, long *i);
-
- // [16/17] Copy the contents of instance 'index' of a multi-valued SEARCH/POST
- // argument called 'name'. Function returns text in 'value'. Length of 'value'
- // string is in 'len', actual length of the value string is returned in 'actualLen'
- // Function returns 'false' if 'index' is out of range or 'name' does not exist.
-
- Boolean HTTPCopyMultipleSrchArg(WWWRequest r, char *name, long index, char *value, long len, long *actualLen);
- Boolean HTTPCopyMultiplePostArg(WWWRequest r, char *name, long index, char *value, long len, long *actualLen);
-
- // -----------------------------------------------------
-
- // [1] Get the handle that holds the HTML response page.
-
- Handle HTMLGetResponseHandle(WWWRequest r);
-
- // [2] Clear out the current response page (except for the
- // HTTP header, and start over.
-
- OSErr HTMLClearPage(Handle r);
-
- // [3] Append contents of handle 'h' to response page.
-
- OSErr HTMLAppendHandle(Handle r, Handle h);
-
- // [4] Append TEXT resource (ID=iTEXTResID) to response page.
-
- OSErr HTMLAppendTEXT(Handle r, long iTEXTResID);
-
- // [5] Append STR resource (ID=iSTRResID) to the response page.
-
- OSErr HTMLAppendString(Handle r, long iSTRResID);
-
- // [6] Append string at location 'index' in STR# resource
- // (ID=iSTRResID) to the response page.
-
- OSErr HTMLAppendIndString(Handle r, long iSTRResID, long index);
-
- // [7] Append local file to response page.
-
- OSErr HTMLAppendFile(Handle r, char *localFileName);
-
- // [8] Append C-string to response page.
-
- OSErr HTMLAppendCString(Handle r, char *cString);
-
- // [9] Append Pascal-string to response page.
-
- OSErr HTMLAppendPString(Handle r, StringPtr pString);
-
- // [10] Append text buffer of length 'len' to response page.
-
- OSErr HTMLAppendBuffer(Handle r, char *buffer, long len);
-
- #endif
-